package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;


/**
 * User: KuznetsovD
 * Date: 25.10.11
 * Time: 16:14
 */
public enum ProgorodMapAttribute implements GISAccountProperty {

//    UseProvider(GisParameter.use_map_provider, MapProviderType.progorod, GISFieldType.BOOLEAN, "true", true, 0L, true),
    ProgorodRoutingUrl(GisParameter.routing_url, MapProviderType.progorod, TEXT, "http://route.tmcrussia.com/cgi/getroute?", true, 1L, true),
    ProgorodForwardGeocodingUrl(GisParameter.geocoding_url, MapProviderType.progorod, TEXT, "http://search2.tmcrussia.com/?a=search&q=%s&z=10&n=%s&st=addr", true, 2L, true),
    ProgorodReverseGeocodingUrl(GisParameter.reverse_geocoding_url, MapProviderType.progorod, TEXT, "http://search2.tmcrussia.com/?a=geocode&lon=%s&lat=%s&is_addr=1&r=1000&n=1&at=3", true, 3L, true),
    ProgorodTraffic(GisParameter.traffic, MapProviderType.progorod, BOOLEAN, "true", true, 4L, true),
    ProgorodUseShortestRoute(GisParameter.use_shortest_route, MapProviderType.progorod, BOOLEAN, "true", true, 5L, true),
    ProgorodEnableCache(GisParameter.enableCache, MapProviderType.progorod, GISFieldType.BOOLEAN, "true", true, 10L, true),
    ProgorodCacheStorageTime(GisParameter.cacheStorageTime, MapProviderType.progorod, GISFieldType.INTEGER, "30", true, 11L, true),
    ProgorodUseMultiplePointsRouting(GisParameter.useMultiplePointsRouting, MapProviderType.progorod, GISFieldType.BOOLEAN, "true", false, 6L, true, true);

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;
    private boolean readOnly = false;

    public boolean isImportant() {
        return important;
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    private ProgorodMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                 boolean required, String groupName, Long order, boolean important, boolean readOnly) {
        this(name, label, type, defaultValue, required, groupName, order, important);
        this.readOnly = readOnly;
    }


    private ProgorodMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                 boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private ProgorodMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                 String defaultValue, boolean required, Long order, boolean important, boolean readOnly) {
        this(parameter, providerType, type, defaultValue, required, order, important);
        this.readOnly = readOnly;
    }


    private ProgorodMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                 String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return readOnly;
    }

}
